package util;

import utils.StringUtil;

public class AgentUtil {

	

	public static String getOs(String agentInfo) {
		if(StringUtil.isEmpty(agentInfo)){
			return "";
		}
		if(agentInfo.indexOf("Mobile")>=0){
			return "Mobile";
		}
		if(agentInfo.indexOf("Windows")>=0){
			return "Windows";
		}
		if(agentInfo.indexOf("Macintosh")>=0){
			return "Macintosh";
		}
		if(agentInfo.indexOf("Linux")>=0){
			return "Linux";
		}
		if(agentInfo.indexOf("Ubuntu")>=0){
			return "Ubuntu";
		}
		
		if(agentInfo.indexOf("iPad")>=0){
			return "iPad";
		}
		if(agentInfo.indexOf("iPhone")>=0){
			return "iPhone";
		}
		if(agentInfo.indexOf("iPod")>=0){
			return "iPod";
		}
		if(agentInfo.indexOf("BlackBerry")>=0){
			return "BlackBerry";
		}
			return "unknown";
	}
	
	public static String getBrowser(String agentInfo) {
		if(StringUtil.isEmpty(agentInfo)){
			return "";
		}
		if(agentInfo.indexOf("MSIE")>=0){
			return "MSIE";
		}
		if(agentInfo.indexOf("Chrome")>=0){
			return "Chrome";
		}
		if(agentInfo.indexOf("Safari")>=0){
			return "Safari";
		}
		if(agentInfo.indexOf("Firefox")>=0){
			return "Firefox";
		}
		if(agentInfo.indexOf("Opera")>=0){
			return "Opera";
		}
		if(agentInfo.indexOf("Netscape")>=0){
			return "Netscape";
		}
		if(agentInfo.indexOf("Konqueror")>=0){
			return "Konqueror";
		}
			return "unknown";
	}
	public static void main(String[] args) {
		String s=AgentUtil.getBrowser("(iPad; CPU OS 7_0_6 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B651 Safari/9537.53");
		System.out.println(s);
	}

	

}
